Immutable Objects in Java
نویسندگان
چکیده
Immutability is a very useful and desirable property for objects. This paper investigates different possible notions of immutability for Java objects, to find out which notion is the most intuitive and useful, both when it comes to ways of enforcing immutability of objects, and when it comes to exploiting information about (im)mutability of objects in program verification and in various static analyses. Our ultimate aim is to agree on a semantics for an immutable keyword in JML.
منابع مشابه
Immutable Objects for a Java-Like Language
We extend a Java-like language with immutability specifications and a static type system for verifying immutability. A class modifier immutable specifies that all class instances are immutable objects. Ownership types specify the depth of object states and enforce encapsulation of representation objects. The type system guarantees that the state of immutable objects does not visibly mutate duri...
متن کاملChanging Hashcodes: Objects, Intialisation, and Collections
Java requires objects’ hashcodes to be consistent with object equality, and to change only when an object’s equality changes. Equality dependent Java collections impose a stricter contextual contract on an objects’ equality, comparability, and hashcode methods: that they cannot change while those objects are in collections. By dynamically profiling 30 Java applications, we have determined that ...
متن کاملObjects Dynamically Changing Class (work in Progress)
This paper represents work in progress; we shall be regularly updating it with proofs, examples and comparisons. Abstract. We suggest language features that allow objects to mutate, i.e. change their class membership at run-time. These features could extend an imperative, typed, class-based, object-oriented language like Java. We give an operational semantics for a mutation operation that chang...
متن کاملOptimized Strings for the Java HotSpot(TM) VM
In Java, a string consists of two parts: the String object itself with metadata such as the string length, and the character array that holds the actual data. Because the character array never changes (strings are immutable), it would be possible to combine the two objects to one object with special support from the virtual machine. Implement this optimization for the Java HotSpotTM VM of Sun M...
متن کاملMining for Safety using Interactive Trace Analysis
This paper presents the results of a trace-based study of object and reference properties on a subset of the DaCapo benchmark suite with the intent to uncover facts about programs that can be leveraged by type systems, compilers and run-times. In particular, we focus on aliasing, and immutability, based on their recent application in the literature. To facilitate analyses like this one, we prev...
متن کامل